package com.pda.xinma.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.pda.xinma.R;
import com.pda.xinma.adapter.RecommendAdapter;
import com.pda.xinma.bean.request.RecommendRequest;
import com.wangshen.base.dialog.base.BaseDialog;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RecommendDialog extends BaseDialog {
    @BindView(R.id.rv_list)
    RecyclerView rvList;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_confirm)
    TextView tvConfirm;
    RecommendRequest recommendRequest;
    OnConfrim onConfrim;
    public RecommendDialog(@NonNull Context context,OnConfrim onConfrim) {
        super(context);
        this.onConfrim=onConfrim;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {

    }


    public void show(RecommendRequest bean) {
        super.show();
        recommendRequest=bean;
        RecommendAdapter adapter=new RecommendAdapter(R.layout.item_recommend,bean.getOrderInfos());
        rvList.setAdapter(adapter);
    }

    @Override
    public int getView() {
        return R.layout.dialog_recommend;
    }

    @OnClick({R.id.tv_cancel, R.id.tv_confirm})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_cancel:
                dismiss();
                break;
            case R.id.tv_confirm:
                if (onConfrim != null){
                    onConfrim.onConfrim();
                    dismiss();
                }
                break;
        }
    }
    public interface OnConfrim{
        void onConfrim();
    }
}
